package com.koron.ticket.work.workline.service.impl;


import com.koron.bean.base.Response;
import com.koron.ticket.work.workline.bean.WorkLine;
import com.koron.ticket.work.workline.bean.WorkLineQuery;
import com.koron.ticket.work.workline.mapper.WorkLineMapper;
import com.koron.ticket.work.workline.service.WorkLineService;
import org.koron.ebs.mybatis.SessionFactory;
import org.koron.ebs.mybatis.TaskAnnotation;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * (TicketWorkLine)表服务实现类
 *
 * @author 朱超
 * @since 2021-11-11 17:19:03
 */
@Service
public class WorkLineServiceImpl implements WorkLineService {

    /**
     * 新增数据
     *
     */
    @Override
    @TaskAnnotation("insert")
    public Response insert(SessionFactory factory, WorkLine workLine) {
        WorkLineMapper mapper = factory.getMapper(WorkLineMapper.class);
        mapper.insert(workLine);
        return Response.success("新增成功");
    }

    /**
     * 批量新增数据
     *
     */
    @Override
    @TaskAnnotation("batchInsert")
    public Response batchInsert(SessionFactory factory, List<WorkLine> list) {
        WorkLineMapper mapper = factory.getMapper(WorkLineMapper.class);
        mapper.batchInsert(list);
        return Response.success("新增成功");
    }

    /**
     * 根据id删除单条数据
     *
     */
    @Override
    @TaskAnnotation("deleteById")
    public Response deleteById(SessionFactory factory, String id) {
        WorkLineMapper mapper = factory.getMapper(WorkLineMapper.class);
        mapper.deleteById(id);
        return Response.success("删除成功");
    }

    /**
     * 更新数据
     *
     */
    @Override
    @TaskAnnotation("update")
    public Response update(SessionFactory factory, WorkLine workLine) {
        WorkLineMapper mapper = factory.getMapper(WorkLineMapper.class);
        mapper.update(workLine);
        return Response.success("更新成功");
    }

    /**
     * 根据id查询单条数据
     *
     */
    @Override
    @TaskAnnotation("getById")
    public Response getById(SessionFactory factory, String id) {
        WorkLineMapper mapper = factory.getMapper(WorkLineMapper.class);
        WorkLineQuery query = new WorkLineQuery();
        query.setId(id);
        WorkLine workLine = mapper.getSingle(query);
        return Response.success(workLine);
    }

    /**
     * 查询单条数据
     *
     */
    @Override
    public WorkLine getSingle(SessionFactory factory, WorkLineQuery workLineQuery) {
        WorkLineMapper mapper = factory.getMapper(WorkLineMapper.class);
        return mapper.getSingle(workLineQuery);
    }

    /**
     * 查询多条数据
     *
     */
    @Override
    public List<WorkLine> getList(SessionFactory factory, WorkLineQuery workLineQuery) {
        WorkLineMapper mapper = factory.getMapper(WorkLineMapper.class);
        return mapper.getList(workLineQuery);
    }

    @Override
    public void deleteByWorkTicketId(SessionFactory factory, String workTicketId) {
        WorkLineMapper mapper = factory.getMapper(WorkLineMapper.class);
        mapper.deleteByWorkTicketId(workTicketId);
    }

}
